//*************************************************************************************
//* 作    者： 邹杭特
//* 创建时间： 2021-10-22 10:23:14
//* 描    述：  

//* ************************************************************************************
using System;
using UnityEngine;
using UFrame.XR;

public class XRInputDebugCtrl : XRInputCtrl
{
    protected override void ProcessInput()
    {
        base.ProcessInput();
        if (Input.GetKey(KeyCode.W))
        {
            var axis = new Vector2(0, 1);
            OnAxisChanged(true,axis);
            if (!m_leftAxisOn)
            {
                m_leftAxisOn = true;
                OnAxisActived(true, m_leftAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.W))
        {
            m_leftAxisOn = false;
            OnAxisActived(true, m_leftAxisOn);
        }

        if (Input.GetKey(KeyCode.S))
        {
            var axis = new Vector2(0, -1);
            OnAxisChanged(true,axis);
            if (!m_leftAxisOn)
            {
                m_leftAxisOn = true;
                OnAxisActived(true, m_leftAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.S))
        {
            m_leftAxisOn = false;
            OnAxisActived(true, m_leftAxisOn);
        }

        if (Input.GetKey(KeyCode.A))
        {
            var axis = new Vector2(-1, 0);
            OnAxisChanged(true,axis);
            if (!m_leftAxisOn)
            {
                m_leftAxisOn = true;
                OnAxisActived(true, m_leftAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.A))
        {
            m_leftAxisOn = false;
            OnAxisActived(true, m_leftAxisOn);
        }

        if (Input.GetKey(KeyCode.D))
        {
            var axis = new Vector2(1, 0);
            OnAxisChanged(true, axis);
            if (!m_leftAxisOn)
            {
                m_leftAxisOn = true;
                OnAxisActived(true, m_leftAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.D))
        {
            m_leftAxisOn = false;
            OnAxisActived(true, m_leftAxisOn);
        }


        if (Input.GetKey(KeyCode.UpArrow))
        {
            var axis = new Vector2(0, 1);
            OnAxisChanged(true,axis);
            if (!m_rightAxisOn)
            {
                m_rightAxisOn = true;
                OnAxisActived(false, m_rightAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.UpArrow))
        {
            m_rightAxisOn = false;
            OnAxisActived(false, m_rightAxisOn);
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            var axis = new Vector2(0, -1);
            OnAxisChanged(false,axis);
            if (!m_rightAxisOn)
            {
                m_rightAxisOn = true;
                OnAxisActived(false, m_rightAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.DownArrow))
        {
            m_rightAxisOn = false;
            OnAxisActived(false, m_rightAxisOn);
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            var axis = new Vector2(-1, 0);
            OnAxisChanged(false,axis);
            if (!m_rightAxisOn)
            {
                m_rightAxisOn = true;
                OnAxisActived(false, m_rightAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.LeftArrow))
        {
            m_rightAxisOn = false;
            OnAxisActived(false, m_rightAxisOn);
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            var axis = new Vector2(1, 0);
            OnAxisChanged(false,axis);
            if (!m_rightAxisOn)
            {
                m_rightAxisOn = true;
                OnAxisActived(false, m_rightAxisOn);
            }
        }
        if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            m_rightAxisOn = false;
            OnAxisActived(false, m_rightAxisOn);
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            OnPrimaryBtnChanged(true, true);
        }
        if (Input.GetKeyUp(KeyCode.Alpha1))
        {
            OnPrimaryBtnChanged(true, false);
        }
        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            OnSecondBtnChanged(true, true);
        }
        if (Input.GetKeyUp(KeyCode.Alpha2))
        {
            OnSecondBtnChanged(true, false);
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            OnGripBtnChanged(true, true);
        }
        if (Input.GetKeyUp(KeyCode.G))
        {
            OnGripBtnChanged(true, false);
        }
    }
}
